﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace PHP
{
	class readWrite
	{
		public void writeData(string nameOutput,List<string> ds)
		{
			FileInfo t = new FileInfo(nameOutput.ToString());
			StreamWriter Tex = null;
			try
			{
				Tex = t.CreateText();
				foreach (var item in ds)
				{
					Tex.WriteLine(item.ToString());
				}
			}
			catch (Exception ex)
			{
				System.Windows.Forms.MessageBox.Show(ex.Message.ToString());
			}
			finally
			{
				Tex.Close();
			}
		}
		public void readData(string nameData,ref List<string>  ds)
		{
			StreamReader sr = null;
			int i = 0;
			try
			{
				sr = File.OpenText(nameData.ToString());
				string input = null;
				while ((input = sr.ReadLine()) != null)
				{
					ds.Add(input);
					i++;
				}
			}
			catch (Exception ex)
			{
				System.Windows.Forms.MessageBox.Show(ex.Message.ToString());
			}
			finally
			{
				sr.Close();
			}
		}
	}
}
